addwindow proto hwnd:DWORD,winHwnd:DWORD
setColumn proto hList:DWORD,lvColumn:DWORD,col:DWORD,uMsg:DWORD
dragquery proto hwnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
String2Dword proc uses ecx edi edx esi String:DWORD
	LOCAL Result:DWORD
	mov Result,0
        mov edi,String
        invoke lstrlen,String
        .while eax!=0
                xor edx,edx
                mov dl,byte ptr [edi]
                sub dl,"0"      ; subtrack each digit with "0" to convert it to hex value
                mov esi,eax
                dec esi
                push eax
                mov eax,edx
                push ebx
                mov ebx,10
                .while esi > 0
                        mul ebx
                        dec esi
                .endw
                pop ebx
                add Result,eax
                pop eax
                inc edi
                dec eax
        .endw
        mov eax,Result
        ret
String2Dword endp
window proc uses ebx edi esi hwnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
	LOCAL @lvColumn:LV_COLUMN
	LOCAL @rect:RECT
	LOCAL @str[258]:BYTE
	LOCAL @lvItem:LV_ITEM
	.if uMsg==WM_INITDIALOG
		invoke LoadIcon,hModuleHandle,win
		.if eax
			invoke SendMessage,hwnd,WM_SETICON,ICON_BIG,eax
		.endif
		invoke ShowWindow,hwnd,SW_SHOW
		invoke LoadIcon,hModuleHandle,drag
		invoke SendDlgItemMessage,hwnd,IDC_IMGDRAG,STM_SETICON,eax,NULL
		invoke GetDlgItem,hwnd,IDC_IMGDRAG
		invoke SetWindowLong,eax,GWL_WNDPROC,addr dragquery
		.if eax
			mov wDragWnd,eax
		.endif
		invoke GetClientRect,hwnd,addr @rect
		add @rect.left,10
		add @rect.top,40
		sub @rect.right,20
		sub @rect.bottom,50
		invoke CreateWindowEx,NULL,
			offset syslistview,NULL,WS_CHILD or WS_VISIBLE or LVS_REPORT or LVS_SHOWSELALWAYS ,@rect.left,@rect.top,@rect.right,@rect.bottom,hwnd,NULL,hModuleHandle,NULL
		mov hList,eax
		invoke SendMessage,hList,LVM_GETEXTENDEDLISTVIEWSTYLE,0,0
		or eax,LVS_EX_FULLROWSELECT or LVS_EX_GRIDLINES
		invoke SendMessage,hList,LVM_SETEXTENDEDLISTVIEWSTYLE,0,eax
		invoke RtlZeroMemory,addr @lvColumn,sizeof LV_COLUMN
		mov @lvColumn.imask,LVCF_TEXT or LVCF_WIDTH or LVCF_FMT or LVCF_SUBITEM
		mov ebx,@rect.right
		sub ebx,@rect.left
		sub ebx,70+150
		mov  @lvColumn.lx,ebx
		mov @lvColumn.pszText,offset szWindowWin
		mov @lvColumn.fmt,LVCFMT_LEFT
		invoke setColumn,hList,addr @lvColumn,0,LVM_INSERTCOLUMN
		mov @lvColumn.lx,150
		mov @lvColumn.pszText,offset szWindowPath
		mov @lvColumn.iSubItem,1
		mov @lvColumn.fmt,LVCFMT_LEFT
		invoke setColumn,hList,addr @lvColumn,1,LVM_INSERTCOLUMN
		mov @lvColumn.lx,70
		mov @lvColumn.pszText,offset szWindowHwnd
		mov @lvColumn.iSubItem,2
		mov @lvColumn.fmt,LVCFMT_CENTER
		invoke setColumn,hList,addr @lvColumn,2,LVM_INSERTCOLUMN
	.elseif uMsg==WM_COMMAND
		mov eax,wParam
		and eax,0ffffh
		.if eax==IDM_EXIT
			invoke SendMessage,hList,LVM_GETITEMCOUNT,0,0
			.while eax
				invoke RtlZeroMemory,addr @lvItem,sizeof @lvItem
				mov @lvItem.iItem,0
				mov @lvItem.iSubItem,2
				mov @lvItem.imask,LVIF_TEXT
				lea ebx,@str
				mov @lvItem.pszText,ebx
				mov @lvItem.cchTextMax,257
				invoke SendMessage,hList,LVM_GETITEM,0,addr @lvItem
				invoke String2Dword,addr @str
				invoke ShowWindow,eax,SW_SHOW
				invoke SendMessage,hList,LVM_DELETEITEM,@lvItem.iItem,0
				invoke SendMessage,hList,LVM_GETITEMCOUNT,0,0
			.endw
			invoke DestroyWindow,hWindowDlg
			invoke DestroyWindow,hList
			mov hWindowDlg,0
		.endif
	.elseif uMsg==WM_NOTIFY
		mov eax,lParam
		assume eax:ptr NMHDR
		mov ebx,hList
		.if [eax].hwndFrom==ebx
			.if [eax].code == NM_DBLCLK
				invoke RtlZeroMemory,addr @lvItem,sizeof @lvItem
				invoke SendMessage,hList,LVM_GETNEXTITEM,-1,LVNI_FOCUSED
				mov @lvItem.iItem,eax
				mov @lvItem.iSubItem,2
				mov @lvItem.imask,LVIF_TEXT
				lea ebx,@str
				mov @lvItem.pszText,ebx
				mov @lvItem.cchTextMax,257
				invoke SendMessage,hList,LVM_GETITEM,0,addr @lvItem
				invoke String2Dword,addr @str
				invoke ShowWindow,eax,SW_SHOW
				invoke SendMessage,hList,LVM_DELETEITEM,@lvItem.iItem,0
			.endif
		.endif
		assume eax:nothing
	.elseif uMsg==WM_SIZE
		invoke GetClientRect,hwnd,addr @rect
		add @rect.left,10
		add @rect.top,40
		sub @rect.right,20
		sub @rect.bottom,50
		invoke MoveWindow,hList,@rect.left,@rect.top,@rect.right,@rect.bottom,TRUE
		invoke RtlZeroMemory,addr @lvColumn,sizeof LV_COLUMN
		mov @lvColumn.imask,LVCF_TEXT or LVCF_WIDTH or LVCF_FMT or LVCF_SUBITEM
		mov ebx,@rect.right
		sub ebx,@rect.left
		sub ebx,70+150
		mov  @lvColumn.lx,ebx
		mov @lvColumn.pszText,offset szWindowWin
		mov @lvColumn.fmt,LVCFMT_LEFT
		invoke setColumn,hList,addr @lvColumn,0,LVM_SETCOLUMN
		mov @lvColumn.lx,150
		mov @lvColumn.pszText,offset szWindowPath
		mov @lvColumn.iSubItem,1
		mov @lvColumn.fmt,LVCFMT_LEFT
		invoke setColumn,hList,addr @lvColumn,1,LVM_SETCOLUMN
		mov @lvColumn.lx,70
		mov @lvColumn.pszText,offset szWindowHwnd
		mov @lvColumn.iSubItem,2
		mov @lvColumn.fmt,LVCFMT_CENTER
		invoke setColumn,hList,addr @lvColumn,2,LVM_SETCOLUMN
	.elseif uMsg==WM_COMMAND
		xor eax,eax
		mov eax,wParam
		and eax,0ffffh
		.if eax==IDC_EDTIP

		.elseif eax==IDC_LSTIP
			mov eax,wParam
			shr eax,16
			.if	ax ==	LBN_DBLCLK

			.endif
		.elseif eax==IDC_BTNFIND

		.endif
	.elseif uMsg==WM_CLOSE
		invoke ShowWindow,hwnd,SW_HIDE
	.else
		mov eax,FALSE
		ret
	.endif
	mov eax,TRUE
	ret

window endp
addwindow proc uses ebx edi esi hwnd:DWORD,winHwnd:DWORD
	LOCAL @lvItem:LV_ITEM
	LOCAL @szBuff[1024]:BYTE
	LOCAL @pid:DWORD
	LOCAL @moduleentry:MODULEENTRY32
	invoke IsWindow,winHwnd
	.if !eax
		ret
	.endif
	invoke RtlZeroMemory,addr @lvItem,sizeof @lvItem
	invoke RtlZeroMemory,addr @szBuff,sizeof @szBuff
	invoke RtlZeroMemory,addr @moduleentry,sizeof @moduleentry
	
	
	
	mov @lvItem.imask,LVIF_TEXT or LVIF_IMAGE
	mov @lvItem.iItem,0
	mov @lvItem.cchTextMax,MAX_PATH
	invoke SendMessage,winHwnd,WM_GETTEXT,1024,addr @szBuff
	lea eax,@szBuff
	mov @lvItem.pszText,eax
	mov @lvItem.iSubItem,0
	invoke SendMessage,hwnd,LVM_INSERTITEM,0,addr @lvItem
	

	
	invoke GetWindowThreadProcessId,winHwnd,addr @pid
	invoke CreateToolhelp32Snapshot,TH32CS_SNAPMODULE,@pid
	mov ebx,eax
	mov @moduleentry.dwSize,sizeof MODULEENTRY32
	invoke Module32First,ebx,addr @moduleentry
	invoke RtlZeroMemory,addr @szBuff,sizeof @szBuff
	invoke wsprintf,addr @szBuff,offset szFormatPath,addr @moduleentry.szExePath
	lea eax,@szBuff
	mov @lvItem.pszText,eax
	mov @lvItem.iSubItem,1
	invoke SendMessage,hwnd,LVM_SETITEM,0,addr @lvItem
	
	
	
	
	
	
	invoke wsprintf,addr @szBuff,offset szFormatHwnd,winHwnd
	lea eax,@szBuff
	mov @lvItem.pszText,eax
	mov @lvItem.iSubItem,2
	invoke SendMessage,hwnd,LVM_SETITEM,0,addr @lvItem
	invoke ShowWindow,winHwnd,SW_HIDE
	ret
addwindow endp
setColumn proc uses ebx edi esi hwnd:DWORD,lpLvColumn:DWORD,col:DWORD,uMSG:DWORD
	invoke SendMessage,hwnd,uMSG,col,lpLvColumn
	ret
setColumn endp
dragquery proc uses ebx edi esi hwnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
	LOCAL @point:POINT
	LOCAL @rect:RECT
	LOCAL @hWin:HWND
	LOCAL @hDesk:HWND
	LOCAL @hDc:HDC
	LOCAL @pen:HPEN
	LOCAL @color:COLORREF
	LOCAL @iRop2:DWORD
	LOCAL @str[512]:BYTE;
	.if uMsg==WM_LBUTTONDOWN
		invoke SetCapture,hwnd
		invoke LoadIcon,hModuleHandle,drag2
		invoke SendMessage,hwnd,STM_SETICON,eax,NULL
		invoke LoadCursor,hModuleHandle,pointcur
		invoke SetCursor,eax
		invoke SetTimer,hwnd,1,600,NULL
	.elseif uMsg==WM_LBUTTONUP
		invoke ReleaseCapture
		invoke KillTimer,hwnd,1
		invoke LoadIcon,hModuleHandle,drag
		invoke SendMessage,hwnd,STM_SETICON,eax,NULL
		invoke GetCursorPos,addr @point
		invoke WindowFromPoint,@point.x,@point.y
		.if eax==hwnd
			ret
		.endif
		mov @hWin,eax
		;grayhwnd
		invoke GetWindow,@hWin,GW_CHILD
		mov ebx,eax
		.while	ebx
			invoke GetWindowRect,ebx,addr @rect
			invoke PtInRect,addr @rect,@point.x,@point.y
			.if eax
				push ebx
				pop @hWin
				.break
			.endif
			invoke GetWindow,ebx,GW_HWNDNEXT
			mov ebx,eax
		.endw
		;grayhwndend
		invoke addwindow,hList,@hWin
	.elseif uMsg==WM_TIMER
		.if wParam==1
			invoke GetCursorPos,addr @point
			invoke WindowFromPoint,@point.x,@point.y
			.if eax==hwnd
				ret
			.endif
			mov @hWin,eax
			;grayhwnd
			invoke GetWindow,@hWin,GW_CHILD
			mov ebx,eax
			.while	ebx
				invoke GetWindowRect,ebx,addr @rect
				invoke PtInRect,addr @rect,@point.x,@point.y
				.if eax
					push ebx
					pop @hWin
					.break
				.endif
				invoke GetWindow,ebx,GW_HWNDNEXT
				mov ebx,eax
			.endw
			;grayhwndend
			invoke GetWindowRect,@hWin,addr @rect
;			sub @rect.bottom,2
;			sub @rect.right,2
;			add @rect.top,2
;			add @rect.left,2
			invoke GetDesktopWindow
			mov @hDesk,eax
			invoke GetWindowDC,@hDesk
			mov @hDc,eax
			invoke SetROP2,@hDc,R2_NOTXORPEN
			mov @iRop2,eax
			mov @color,000000ffdh
			invoke CreatePen,PS_SOLID,3,@color
			mov @pen,eax
			invoke SelectObject,@hDc,@pen
			mov @pen,eax
			invoke Rectangle,@hDc,@rect.left,@rect.top,@rect.right,@rect.bottom
			invoke Sleep,300
			invoke Rectangle,@hDc,@rect.left,@rect.top,@rect.right,@rect.bottom
			invoke SetROP2,@hDc,@iRop2
			invoke SelectObject,@hDc,@pen
			mov @pen,eax
			invoke DeleteObject,@pen
			invoke ReleaseDC,@hDesk,@hDc
		.endif
	.else
		invoke CallWindowProc,wDragWnd,hwnd,uMsg,wParam,lParam
	.endif
	ret
dragquery endp 	